home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / mtools2-xenixpatch < prev    next >
Encoding:
Text File  |  1992-01-11  |  10.9 KB  |  362 lines

  1. Newsgroups: comp.sources.unix
  2. From: vancleef@netcom.netcom.com (Henry van Cleef)
  3. Subject: v25i103: xenix patches for mtools2
  4. Sender: sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: vancleef@netcom.netcom.com (Henry van Cleef)
  8. Posting-Number: Volume 25, Issue 103
  9. Archive-Name: mtools2-xenixpatch
  10.  
  11. This patch to Emmett Gray's Mtools revision 2.0.5 was produced from the
  12. changes I made to the distribution to install mtools on my Xenix 286
  13. system.  There were a number of places where the Xenix int of 16 bits caused
  14. trouble, particularly with use of mtools on hard disks.  
  15.  
  16. The table in devices.c is one that illustrates several ways of handling
  17. /dev/drivers.  It is set up to work with two hard disks, one of which has
  18. two DOS partitions.  
  19.  
  20. You will have to change the permissions on the /dev/hd* disks to use this
  21. code.  I did not set these programs up for setuid/setgid.  
  22.  
  23. My thanks to Emmett Gray for writing mtools.  It was a fairly easy port as
  24. things go with Xenix.  I had to prepare this patch file on my 3b1 Unix PC
  25. because Xenix 286 does not have a context switch in diff, and the gnu diff
  26. program blows up the compiler because the macros in regex.c are too big.  So
  27. it goes.
  28.  
  29. WARNING:  If you have problems, they will most likely be with the fat
  30. calculations in fat_read.c and fat_write.c and show up when working with
  31. hard disks.  BACK UP YOUR SYSTEM before you try writing to the hard disk.  I
  32. blew up my hard disk fat a number of times and was glad I had nothing sacred
  33. on those disks.  A good check is to see that file sizes and free space are
  34. reported correctly with mdir, but this does not test fat_write.c.  Take a
  35. careful look at the patches for these two files---the context lines,
  36. particularly the ones showing showing start = num * 2 are important---this
  37. was a bug in earlier releases.  
  38.  
  39.     vancleef@netcom.netcom.com (Henry van Cleef)
  40.  
  41. #!/bin/sh
  42. # This is a shell archive (produced by shar 3.49)
  43. # To extract the files from this archive, save it to a file, remove
  44. # everything above the "!/bin/sh" line above, and type "sh file_name".
  45. #
  46. # made 01/12/1992 05:09 UTC by install@jennifer
  47. # Source directory /users/xenix/patches
  48. #
  49. # existing files will NOT be overwritten unless -c is specified
  50. #
  51. # This shar contains:
  52. # length  mode       name
  53. # ------ ---------- ------------------------------------------
  54. #   7978 -rw-r--r-- mtools.patch
  55. #
  56. # ============= mtools.patch ==============
  57. if test -f 'mtools.patch' -a X"$1" != X"-c"; then
  58.     echo 'x - skipping mtools.patch (File already exists)'
  59. else
  60. echo 'x - extracting mtools.patch (Text)'
  61. sed 's/^X//' << 'SHAR_EOF' > 'mtools.patch' &&
  62. diff -c ../mtools/Makefile .//Makefile
  63. *** ../mtools/Makefile    Sat Jan  4 18:59:15 1992
  64. --- .//Makefile    Sat Jan 11 23:21:39 1992
  65. ***************
  66. *** 3,17 ****
  67. X  #
  68. X  # check the Configure file for some examples of device-specific setups
  69. X  # Berkeley flavors of Unix should include -DBSD in the CFLAGS
  70. X  
  71. ! CFLAGS    = -O
  72. ! LDFLAGS    = -s
  73. X  LD    = cc
  74. X  LINT    = lint
  75. X  SHLIB    =
  76. ! SHAR    = shar -a
  77. X  BINDIR    = /usr/local/bin
  78. ! MANSECT    = 1
  79. X  MANDIR    = /usr/man/man$(MANSECT)
  80. X  #
  81. X  # for AT&T Unix PC 7300/3b1 style shared libraries.
  82. --- 3,18 ----
  83. X  #
  84. X  # check the Configure file for some examples of device-specific setups
  85. X  # Berkeley flavors of Unix should include -DBSD in the CFLAGS
  86. + # This setup is for Xenix 286.  A stack of 5000 seems to work OK.
  87. X  
  88. ! CFLAGS    = -O -M2e
  89. ! LDFLAGS    = -s -M2e -i -F 5000  #Small model, separate I and D space
  90. X  LD    = cc
  91. X  LINT    = lint
  92. X  SHLIB    =
  93. ! SHAR    = shar 
  94. X  BINDIR    = /usr/local/bin
  95. ! MANSECT    = LOCAL
  96. X  MANDIR    = /usr/man/man$(MANSECT)
  97. X  #
  98. X  # for AT&T Unix PC 7300/3b1 style shared libraries.
  99. ***************
  100. *** 116,122 ****
  101. X      cp Mkmanifest.1 $(MANDIR)/mkmanifest.$(MANSECT)
  102. X  
  103. X  clean:
  104. !     rm $(PROGS)
  105. X  
  106. X  lint:
  107. X      $(LINT) mattrib.c buf_read.c buf_write.c devices.c dir_read.c \
  108. --- 117,126 ----
  109. X      cp Mkmanifest.1 $(MANDIR)/mkmanifest.$(MANSECT)
  110. X  
  111. X  clean:
  112. !     rm -f $(PROGS) core *.o
  113. ! relink:
  114. !     rm -f $(PROGS)
  115. X  
  116. X  lint:
  117. X      $(LINT) mattrib.c buf_read.c buf_write.c devices.c dir_read.c \
  118. diff -c ../mtools/buf_read.c .//buf_read.c
  119. *** ../mtools/buf_read.c    Sat Jan  4 18:59:30 1992
  120. --- .//buf_read.c    Sat Jan 11 17:09:06 1992
  121. ***************
  122. *** 27,32 ****
  123. --- 27,34 ----
  124. X      long where, tail, lseek();
  125. X      void perror(), exit(), disk_flush();
  126. X  
  127. +     long debug_num;
  128. X                      /* don't use cache? */
  129. X      if (disk_size == 1) {
  130. X          where = (start * MSECTOR_SIZE) + disk_offset;
  131. diff -c ../mtools/devices.c .//devices.c
  132. *** ../mtools/devices.c    Sat Jan  4 18:59:32 1992
  133. --- .//devices.c    Sat Jan 11 18:05:52 1992
  134. ***************
  135. *** 46,51 ****
  136. --- 46,77 ----
  137. X  };
  138. X  #endif /* SPARC */
  139. X  
  140. + /* The following table is for a 1.44 3.5 drive in A:, a 1.2 5.25 
  141. +  * drive in B:, and two hard disks, each beginning with a DOS 
  142. +  * partition.  Drives H: and L: force drive A: to hi and lo 
  143. +  * density; X: and Y: do the same for B:.  This shows all the
  144. +  * possibilities.  /dev/install and /dev/install1 are the preferred
  145. +  * driver entries.  If you do not have a second hard disk, do not
  146. +  * include an entry for /dev/hd1d. (Table added by H. van Cleef,
  147. +  * 12-20-91)
  148. +  */
  149. + #ifdef M_XENIX
  150. + struct device devices[] = {
  151. +     {'A', "/dev/install", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18},
  152. +     {'A', "/dev/install", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},
  153. +     {'B', "/dev/install1", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15},
  154. +     {'B', "/dev/install1", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},
  155. +     {'C', "/dev/hd0d", 0L, 16, 0, (int (*) ()) 0, 0, 0, 0},
  156. +     {'D', "/dev/hd1d", 0L, 16, 0, (int (*) ()) 0, 0, 0, 0},
  157. +     {'E', "/dev/hd12", 0L, 16, 0, (int (*) ()) 0, 0, 0, 0},
  158. +     {'H', "/dev/fd0135ds18", 0L, 12, 0, (int (*) ()) 0, 80, 2, 18},
  159. +     {'L', "/dev/fd0135ds9", 0L, 12, 0, (int (*) ()) 0, 80, 2, 9},
  160. +     {'X', "/dev/fd196ds15", 0L, 12, 0, (int (*) ()) 0, 80, 2, 15},
  161. +     {'Y', "/dev/fd148ds9", 0L, 12, 0, (int (*) ()) 0, 40, 2, 9},
  162. +     {'\0', (char *) NULL, 0L, 0, 0, (int (*) ()) 0, 0, 0, 0}
  163. + };
  164. + #endif /*M_XENIX*/
  165. X  #ifdef UNIXPC
  166. X  #include <sys/gdioctl.h>
  167. X  #include <fcntl.h>
  168. diff -c ../mtools/fat_read.c .//fat_read.c
  169. *** ../mtools/fat_read.c    Sat Jan  4 18:59:54 1992
  170. --- .//fat_read.c    Sat Jan 11 01:12:31 1992
  171. ***************
  172. *** 17,24 ****
  173. X  fat_decode(num)
  174. X  unsigned int num;
  175. X  {
  176. !     unsigned int fat, fat_hi, fat_low, byte_1, byte_2;
  177. !     int start;
  178. X  
  179. X      if (fat_bits == 12) {
  180. X          /*
  181. --- 17,24 ----
  182. X  fat_decode(num)
  183. X  unsigned int num;
  184. X  {
  185. !     unsigned long fat, fat_hi, fat_low, byte_1, byte_2;
  186. !     long start;
  187. X  
  188. X      if (fat_bits == 12) {
  189. X          /*
  190. ***************
  191. *** 60,66 ****
  192. X           */
  193. X                      /* which bytes contain the entry */
  194. X          start = num * 2;
  195. !         if (start <= 3 || start + 1 > (fat_len * MSECTOR_SIZE))
  196. X              return(1);
  197. X  
  198. X          fat = (*(fat_buf + start + 1) * 0x100) + *(fat_buf + start);
  199. --- 60,66 ----
  200. X           */
  201. X                      /* which bytes contain the entry */
  202. X          start = num * 2;
  203. !         if (start <= 3 || start + 1 > ((long)fat_len * MSECTOR_SIZE))
  204. X              return(1);
  205. X  
  206. X          fat = (*(fat_buf + start + 1) * 0x100) + *(fat_buf + start);
  207. ***************
  208. *** 76,82 ****
  209. X  fat_read(start)
  210. X  int start;
  211. X  {
  212. !     int buflen;
  213. X      char *malloc();
  214. X      void perror(), exit(), disk_read();
  215. X                      /* only the first copy of the FAT */
  216. --- 76,82 ----
  217. X  fat_read(start)
  218. X  int start;
  219. X  {
  220. !     long buflen;
  221. X      char *malloc();
  222. X      void perror(), exit(), disk_read();
  223. X                      /* only the first copy of the FAT */
  224. diff -c ../mtools/fat_write.c .//fat_write.c
  225. *** ../mtools/fat_write.c    Sat Jan  4 18:59:55 1992
  226. --- .//fat_write.c    Sat Jan 11 01:13:49 1992
  227. ***************
  228. *** 14,20 ****
  229. X  unsigned int num;
  230. X  unsigned int code;
  231. X  {
  232. !     int start;
  233. X  
  234. X      if (fat_bits == 12) {
  235. X          /*
  236. --- 14,20 ----
  237. X  unsigned int num;
  238. X  unsigned int code;
  239. X  {
  240. !     long start;
  241. X  
  242. X      if (fat_bits == 12) {
  243. X          /*
  244. ***************
  245. *** 52,58 ****
  246. X           */
  247. X                      /* which bytes contain the entry */
  248. X          start = num * 2;
  249. !         if (start <= 3 || start + 1 > (fat_len * MSECTOR_SIZE))
  250. X              return(1);
  251. X  
  252. X          *(fat_buf + start + 1) =  code / 0x100;
  253. --- 52,58 ----
  254. X           */
  255. X                      /* which bytes contain the entry */
  256. X          start = num * 2;
  257. !         if (start <= 3 || start + 1 > ((long)fat_len * MSECTOR_SIZE))
  258. X              return(1);
  259. X  
  260. X          *(fat_buf + start + 1) =  code / 0x100;
  261. ***************
  262. *** 70,76 ****
  263. X  void
  264. X  fat_write()
  265. X  {
  266. !     int fat_start, buflen, dups;
  267. X      void disk_write();
  268. X  
  269. X      if (fd < 0)
  270. --- 70,76 ----
  271. X  void
  272. X  fat_write()
  273. X  {
  274. !     long fat_start, buflen, dups;
  275. X      void disk_write();
  276. X  
  277. X      if (fd < 0)
  278. diff -c ../mtools/mdir.c .//mdir.c
  279. *** ../mtools/mdir.c    Sat Jan  4 19:00:07 1992
  280. --- .//mdir.c    Sat Jan 11 18:12:58 1992
  281. ***************
  282. *** 78,86 ****
  283. X              if (last_drive != 'x') {
  284. X                  blocks = getfree() * MSECTOR_SIZE;
  285. X                  if (!files)
  286. !                     printf("File \"%s\" not found\n\n", newname);
  287. X                  else
  288. !                     printf("     %3d File(s)     %6ld bytes free\n\n", files, blocks);
  289. X              }
  290. X              if (init(drive, 0)) {
  291. X                  fprintf(stderr, "%s: Cannot initialize '%c:'\n", argv[0], drive);
  292. --- 78,86 ----
  293. X              if (last_drive != 'x') {
  294. X                  blocks = getfree() * MSECTOR_SIZE;
  295. X                  if (!files)
  296. !                     printf("File \"%s\" not found %8ld bytes free\n\n", newname,blocks);
  297. X                  else
  298. !                     printf("     %3d File(s)     %8ld bytes free\n\n", files, blocks);
  299. X              }
  300. X              if (init(drive, 0)) {
  301. X                  fprintf(stderr, "%s: Cannot initialize '%c:'\n", argv[0], drive);
  302. ***************
  303. *** 196,204 ****
  304. X  
  305. X      blocks = getfree() * MSECTOR_SIZE;
  306. X      if (!files)
  307. !         printf("File \"%s\" not found\n", newname);
  308. X      else
  309. !         printf("     %3d File(s)     %6ld bytes free\n", files, blocks);
  310. X      close(fd);
  311. X      exit(0);
  312. X  }
  313. --- 196,204 ----
  314. X  
  315. X      blocks = getfree() * MSECTOR_SIZE;
  316. X      if (!files)
  317. !         printf("File \"%s\" not found %8ld bytes free\n\n", newname,blocks);
  318. X      else
  319. !         printf("     %3d File(s)     %8ld bytes free\n", files, blocks);
  320. X      close(fd);
  321. X      exit(0);
  322. X  }
  323. diff -c ../mtools/msdos.h .//msdos.h
  324. *** ../mtools/msdos.h    Sat Jan  4 19:00:29 1992
  325. --- .//msdos.h    Sat Jan 11 14:56:34 1992
  326. ***************
  327. *** 2,10 ****
  328. X   * msdos common header file
  329. X   */
  330. X  
  331. ! #define MSECTOR_SIZE    512        /* MSDOS sector size in bytes */
  332. X  #define MDIR_SIZE    32        /* MSDOS directory size in bytes */
  333. ! #define MAX_CLUSTER    8192        /* largest cluster size */
  334. X  #define MAX_PATH    128        /* largest MSDOS path length */
  335. X  #define MAX_DIR_SECS    64        /* largest directory (in sectors) */
  336. X  
  337. --- 2,10 ----
  338. X   * msdos common header file
  339. X   */
  340. X  
  341. ! #define MSECTOR_SIZE    512L        /* MSDOS sector size in bytes */
  342. X  #define MDIR_SIZE    32        /* MSDOS directory size in bytes */
  343. ! #define MAX_CLUSTER    8192L        /* largest cluster size */
  344. X  #define MAX_PATH    128        /* largest MSDOS path length */
  345. X  #define MAX_DIR_SECS    64        /* largest directory (in sectors) */
  346. X  
  347. Only in ./: mtools.patch
  348. SHAR_EOF
  349. chmod 0644 mtools.patch ||
  350. echo 'restore of mtools.patch failed'
  351. Wc_c="`wc -c < 'mtools.patch'`"
  352. test 7978 -eq "$Wc_c" ||
  353.     echo 'mtools.patch: original size 7978, current size' "$Wc_c"
  354. fi
  355. exit 0
  356. -- 
  357. Hank van Cleef---The Union Institute---History of Science and Technology
  358. Unix, X11, networked systems  vancleef@netcom.com, vancleef@tmn.com  
  359.